#!/usr/bin/env python2.7

# bender.py

import os, sys
#import re
#from datetime import datetime, timedelta
#from dateutil.parser import parse

#from mpl_toolkits.basemap import Basemap
#from matplotlib import mlab
#from netCDF4 import Dataset
from PySide.QtCore import *
from PySide.QtGui import *
from ui_settinger import *
from metlib.kits import Null, Setter

class Settinger(QWidget, Ui_SettingerWidget, Setter):
    def __init__(self, parent=None, itemlist=None):
        super(Settinger, self).__init__(parent)
        self.setupUi(self)
        self.parent = parent
        self.load_setting_items(itemlist)

        self.loadButton.clicked.connect(self.load)
        self.saveButton.clicked.connect(self.save)

    def load_setting_items(self, itemlist):
        self.setting_items = itemlist

    def load(self):
        if self.parent:
            self.parent.load_setting(self.fname, prefix=self.prefix)

    def save(self):
        if self.parent:
            self.parent.save_setting(self.fname, prefix=self.prefix, attrs=self.setting_items)

    @property
    def fname(self):
        return self.fnameEdit.text()

    @fname.setter
    def fname(self, value):
        self.fnameEdit.setText(value)

    @property
    def prefix(self):
        return self.prefixEdit.text()

    @prefix.setter
    def prefix(self, value):
        self.prefixEdit.setText(value)
if __name__ == '__main__':
    pass
